package com.woniuxy.lab.woniu_lab.config;

import com.woniuxy.lab.woniu_lab.interceptor.Authentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

// 配置拦截器 用于令牌校验
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Resource
    private Authentication authentication;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authentication)
                .excludePathPatterns(
                        "/favicon.ico",
                        "/swagger-ui.html/**",
                        "/webjars/**",
                        "/swagger-resources**",
                        "/swagger-ui.html",
                        "/swagger-resources/**",
                        "/csrf",
                        "/v2/**",
                        "/error",
                        "/",
                        "/account/alipayCallback**",// 支付宝异步回调
                        "/js/**", "/css/**",
                        "/**");// 不拦截的请求
    }
}